package com.cxyzy.demo.viewmodels

import androidx.lifecycle.ViewModel
import com.cxyzy.demo.db.bean.User
import com.cxyzy.demo.db.repository.UserRepository
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch

class UserViewModel internal constructor(private val userRepository: UserRepository) : ViewModel() {
    val userList = userRepository.getUserList()
    fun deleteAll()
    {
        GlobalScope.launch {
            userRepository.deleteAll()
        }
    }
    fun initData() {
        GlobalScope.launch {
            (1..1000).forEach {
                userRepository.addUser("user$it")
            }
        }
    }
}